package com.xiaotu.storage;

import java.util.Date;

import org.springframework.stereotype.Component;

import com.xiaotu.common.util.Constants;
import com.xiaotu.common.util.DataRedisKeyUtils;
import com.xiaotu.storage.converter.AConverter;
import com.xiaotu.storage.converter.ConverterFactory;
import com.xiaotu.storage.model.CacheDataModel;

import net.sf.json.JSONObject;

/**
 * @类名 TVProCommentStorageProcessor
 * @日期 2017年2月21日
 * @作者 高海军
 * @功能 电视剧专业影评内容存储类
 */
@Component("TVProCommentStorageProcessor")
public class TVProCommentStorageProcessor extends AHSetStorageProcessor
{
	@Override
	protected String getRedisKey(Date date)
	{
		return DataRedisKeyUtils.getKey(
				Constants.DataRedisKey.TV_Professional_Content_YYYYMMDD, date);
	}
	
	@Override
	public String process(JSONObject target, CacheDataModel cacheData,
			Date date)
	{
		this.validateAllNotEmpty(target, "resourcesiteid", "tvId",
				"commentuser", "commentdate", "title", "comment");// 校验
		
		return this.list2CSVLine(ConverterFactory.convert(target,
				new String[] { "resourcesiteid", "tvId", "tvName",
						"commentuser", "commentdate", "title", "comment", "url",
						"up", "down", "timestamp" },
				new String[] { AConverter.STRING_CONVERT,
						AConverter.STRING_CONVERT, AConverter.STRING_CONVERT,
						AConverter.STRING_CONVERT, AConverter.DATE_CONVERT,
						AConverter.STRING_CONVERT, AConverter.STRING_CONVERT,
						AConverter.STRING_CONVERT, AConverter.INTEGER_CONVERT,
						AConverter.INTEGER_CONVERT,
						AConverter.TIMESTAMP_CONVERT },
				new boolean[] { true, true, true, true, true, true, true, true,
						true, true, true }));
	}
	
	@Override
	public String getDataType()
	{
		return Constants.PageDataType.TV_COMMENT;
	}
	
	@Override
	public String getTaskType()
	{
		return Constants.SpiderTaskType.TV_PRO_COMMENT;
	}
}
